import { useState } from 'react'
import './App.css'

function App() {
  const [age, setAge] = useState(20);
  const [name,setName] = useState('大家一起喜羊羊');

  const handleName = () =>{
    setName('欢乐喜羊羊');
  }
  const handleadd = () =>{
    setAge(age+1)
  }
  const handleJian = () =>{
    setAge(age-1)
  }

  return (
   <div>
    <h1>
      <p>{name}</p>
      <p>{age}</p>
    </h1>
    <button onClick={()=>handleName()}>更改名字</button>
    <button onClick={()=>handleadd()}>年龄 + 1</button>
    <button onClick={()=>handleJian()}>年龄 - 1</button>
   </div>
  )
}

export default App
